<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
	<script type="text/javascript">
		/*
		 * class 里的子类集成
		 * 1.子类的__proto__，表示构造函数的集成，执行父类构造函数
		 * 2.子类prototype属性的__proto___,表示方法的集成，指向父类的prototype
		 * 原因:内部的继承用的是Object.setPrototypeOf()方法
		 */
		//ES5
		function Ball(){

		}

		function Football (){
			Ball.call(this);
		}

		//ES6
		class Father{

		}

		class Son extends Father{

		}
		//构造函数,关系没有变
		console.log(
			'构造函数',
			Ball.__proto__ === Ball.prototype,
			Father.__proto__ === Father.prototype,

			Ball.__proto__ === Function.prototype,
			Father.__proto__ === Function.prototype
		);

		//实例（关闭没有变）
		console.log(
			'实例函数',
			new Ball().__proto__ === Ball.prototype,
			new Father().__proto__ === Father.prototype
		);

		//子类
		console.log(
			'子类函数',
			Football.__proto__ === Function.prototype,
			Football.__proto__ === Ball,

			Son.__proto__ === Function.prototype,
			Son.__proto__ === Father   //true

			//ES6,子类的__proto指向父类
		);

		console.log(
			'子类prototype属性的__proto___',
			Football.prototype.__proto__ === Object.prototype,

			Son.prototype.__proto__ === Object.prototype,
			Son.prototype.__proto__ === Father.prototype

			//ES6 里面，子类prototype属性__proto__，指向父类的prototype
		);

		//原因
		{
			class Father{};
			class Son{};
			//Son的实例继承Father的实例
			Object.setPrototypeOf(Son.prototype,Father.prototype);

			//等同于
			Son.prototype.__proto__ = Father.prototype;
			
			//Son继承Father 的私有属性
			Object.setPrototypeOf(Son,Father);

			//等同于
			Son.__proto__ = Father;

			Object.setPrototypeOf = function(obj,proto){
				obj.__proto__ = proto;
				return obj;
			}

		}

	</script>
</body>
</html>